import axios from './axios'
import qs from 'qs'
import { apiUrl, appUrl } from '@/config/config'

// 按班级查询班级套餐统计数据
export const getStatisticsApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/safety/api/device/studentDevice/orderStatisticsByClass/' + params,
      method: 'get'
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 获取学生信息
export const getStudentApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/bdc/api/app/student',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data.items)
    }).catch(err => {
      reject(err)
    })
  })
}

// 获取家长枚举字典
export const getDictionariesApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/bdc/api/app/dictionaryvalue',
      method: 'get',
      params
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

// 创建更新家长绑定关系
export const postTparentApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/bdc/api/app/student/' + params.id + '/parentMappings',
      method: 'post',
      data: params.data
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

// 上传人脸图片功能
export const putFaceApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/bdc/api/app/student/' + params.id,
      method: 'put',
      data: params.data
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}

//  获取设备电话号码
export const getPhoneApi = (params) => {
  return new Promise((resolve, reject) => {
    axios({
      url: appUrl + '/safety/api/device/studentDevice',
      method: 'get',
      params
    }).then(res => {
      resolve(res)
    }).catch(err => {
      reject(err)
    })
  })
}